
#include "Audio.h"


Audio::Audio(string fileName, int type)
{
	if (type == 0)
	{
		sound = Mix_LoadWAV(fileName.c_str());
		music = NULL;
	} else
	{
		music = Mix_LoadMUS(fileName.c_str());
		sound = NULL;
	}
}


Audio::~Audio()
{
	Mix_FreeMusic(music);
	Mix_FreeChunk(sound);
}


void Audio::Play(int n)
{
	if (music != NULL)
		Mix_PlayMusic(music, n);
	else
		channel = Mix_PlayChannel(-1, sound, n);
}


void Audio::Stop()
{
	Mix_FadeOutMusic(50);
	Mix_HaltChannel(channel);
}


